package 反射第二遍.demo21;

import java.lang.reflect.Method;

/**
 * @author wql
 * @version 1.0
 * @date 2022/10/27 16:06
 */

public class Wang {
    public static void main(String[] args) throws Exception{
        Class<hehe> heheClass = hehe.class;
        Method play = heheClass.getDeclaredMethod("play", String.class, Integer.class);
        Object hehe = heheClass.newInstance();
        Object invoke = play.invoke(hehe,"老蓝",888 );
        System.out.println(invoke);
        Method noeat = heheClass.getDeclaredMethod("noeat");
        Object invoke1 = noeat.invoke(hehe);
        System.out.println(invoke1);
    }
}
class  haha{
    public void eat(){
        System.out.println("haha的eat方法");
    }
    public void drink(){
        System.out.println("haha的drink方法");
    }
}
class hehe extends haha {
    public void noeat() {
        System.out.println("hehe的noeat方法");
    }

    public String play(String name, Integer num) {
        System.out.println("hehe的paly方法" + name);
            return "666";
    }


}